<!doctype html>
<html lang=zh class=digimon>
<head>
<meta charset=utf-8>
<meta name=keywords content="">
<meta name=description content="">
<meta http-equiv=Cache-Control content="no-cache, no-store, must-revalidate">
<meta http-equiv=Pragma content=no-cache><meta http-equiv=Expires content=0>
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{$sets['title']}</title>
<meta name=screen-orientation content=portrait>
<meta name=full-screen content=yes><meta name=x5-orientation content=portrait>
<meta name=x5-fullscreen content=true>
<meta name=msapplication-tap-highlight content=no>
<link rel="stylesheet" href="<?php echo MODULE_URL;?>template/mobile/css/digimon-new.css?t=grd">
</head>
<body>
	<div style="display: none;">
		<img src="{$user_photo}">
	</div>
	<div id="time-bar">
		<div class="time">
	      <div class="time_right"></div>
	      <div class="time_left">
	      	<img src="<?php echo MODULE_URL;?>template/mobile/images/time_left.png" style="width:30px">
	      </div>
	      <div class="time_num">
	        <span>0</span>
	        <span>0</span>
	        <span>:</span>
	        <span>0</span>
	        <span>0</span>
	      </div>    
	    </div>
	</div>
	<a class="button disabled" href=#>下一题</a>
	<div class=wrapper>

		{loop $list $item}
		{php if($item['type']=="picture"){ }
		<div class="page type-2 <?php if($item['qid']=='1'){echo 'active';}?>" id=page-{$item['qid']}>
			<div class=main>
				<div class=question>
					<span class=num>{$item['qid']}</span>
					<span class=text>{$item['question']}</span>
				</div>
				<ul class="options clearfix">
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_a']}></figure>
						<p>{$item['pic_a_intro']}</p>
					</li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_b']}></figure>
						<p>{$item['pic_b_intro']}</p>
					</li>
					<li style="clear:both;display:block;width:100%"></li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_c']}></figure>
						<p>{$item['pic_c_intro']}</p>
					</li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_d']}></figure>
						<p>{$item['pic_d_intro']}</p>
					</li>
				</ul>
			</div>
		</div>
		{php }else{ }
		<div class="page type-text <?php if($item['qid']=='1'){echo 'active';}?>" id=page-{$item['qid']}>
			<div class=main>
				<div class=question>
					<span class=num>{$item['qid']}</span>
					<span class=text>{$item['question']}</span>
				</div>
				<ul class="options clearfix">
					<li><p>A. {$item['ans_a']}</p></li>
					<li><p>B. {$item['ans_b']}</p></li>
					<li><p>C. {$item['ans_c']}</p></li>
					<li><p>D. {$item['ans_d']}</p></li>
				</ul>
			</div>
		</div>
		{php } }
		{/loop}
		
		<div class=page id=page-not>
			<div class=main>
				<h3>下面是最后一题，也是最重要的一题...</h3>
				<div class=fox></div>
			</div>
		</div>

		{loop $last_one $item}
		{php if($item['type']=="picture"){ }
		<div class="page type-2 <?php if($item['qid']=='1'){echo 'active';}?>" id=page-{$item['qid']}>
			<div class=main>
				<div class=question>
					<span class=num>{$item['qid']}</span>
					<span class=text>{$item['question']}</span>
				</div>
				<ul class="options clearfix">
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_a']}></figure>
						<p>{$item['pic_a_intro']}</p>
					</li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_b']}></figure>
						<p>{$item['pic_b_intro']}</p>
					</li>
					<li style="clear:both;display:block;width:100%"></li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_c']}></figure>
						<p>{$item['pic_c_intro']}</p>
					</li>
					<li>
						<figure><img src={$_W['attachurl']}{$item['pic_d']}></figure>
						<p>{$item['pic_d_intro']}</p>
					</li>
				</ul>
			</div>
		</div>
		{php }else{ }
		<div class="page type-text <?php if($item['qid']=='1'){echo 'active';}?>" id=page-{$item['qid']}>
			<div class=main>
				<div class=question>
					<span class=num>{$item['qid']}</span>
					<span class=text>{$item['question']}</span>
				</div>
				<ul class="options clearfix">
					<li><p>A. {$item['ans_a']}</p></li>
					<li><p>B. {$item['ans_b']}</p></li>
					<li><p>C. {$item['ans_c']}</p></li>
					<li><p>D. {$item['ans_d']}</p></li>
				</ul>
			</div>
		</div>
		{php } }
		{/loop}
		<div class=page id=page-share>
			<div class=content>
				<div class=geek></div>
				<div class=wrap>
					<div class=headimg><img src="{$user_photo}"></div>
					<div class=score>
						<div class=line></div>
						<div class=text id=score>0</div>
					</div>
					<p id=praise></p>
					<h4>在微信中关注“{$_W['uniaccount']['name']}”，回复“{$sets['copyright']}”，可收到测试题答案。</h4>
					<h4 id=tcent></h4>
				</div>
			</div>
			<div class=share>- 欢迎分享给你的朋友 -</div>
			<div class=adv><a href=""><img src="{$_W['attachurl']}{$sets['adv']}"></a></div>
		</div>
		
	</div>
	<script src="<?php echo MODULE_URL;?>template/mobile/js/digimon-new-lib.js"></script>
	<script src="<?php echo MODULE_URL;?>template/mobile/js/digimon-new-app.js"></script>

<script type="text/javascript">
function clock_change()
{
	var set_time = <?php echo $sets['duration']?>;
	var span = $("#time-bar .time_num span");
	var lost_time = 0;
	objtime = setInterval(function(){
		lost_time++;
		var minute = parseInt(lost_time/60);
		
		if(minute.toString().length>1){
			span[0].innerHTML = minute.toString().substr(0, 1);
			span[1].innerHTML = minute.toString().substr(1, 1);
		}else{
			span[0].innerHTML = '0';
			span[1].innerHTML = minute;
		}
		var second = lost_time%60;
		if(second.toString().length>1){
			span[3].innerHTML = second.toString().substr(0, 1);
			span[4].innerHTML = second.toString().substr(1, 1);
		}else{
			span[3].innerHTML = '0';
			span[4].innerHTML = second;
		}
		if(lost_time >= set_time*60 && set_time>0){ 
			clearInterval(objtime);
			$(".page").not("#page-share").hide();$("#page-share").addClass("active").show();
		}
		
	},1000);
	
}
jQuery(document).ready(function(e) {
	var total={$total};
	var per_cent = Math.round(100/total);
	var ans_json=<?php echo json_encode($answer);?>;
	var jifen_json=<?php echo json_encode($jifen);?>;
	var result_json=<?php echo json_encode($result);?>;
	var link_num = 0;
	function roundReloaded(num, dec) {
            var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
            return result;
    }
    var t = {
        scoreText: result_json,
        duration: 400,
        answer: ans_json,
		jifen: jifen_json
    },
    n = {
        questionList: [],
        currIndex: 0,
        isRunning: !1,
        isWeixin: function() {
            var e = navigator.userAgent.toLowerCase();
            return "micromessenger" == e.match(/MicroMessenger/i) ? !0 : !1
        },

        getScore: function() {
            for (var e = this,
            n = 0,
            rcount = 0,
            total_cent = 0,
            i = t.scoreText[0].praise, s = t.scoreText[0].weixin1+n+t.scoreText[0].weixin2, r = !1, a = 0; a < e.questionList.length; a++) {
                var o = e.questionList[a];
                null != o.select && o.select + "" == o.answer + "" && (rcount += 1) && (total_cent += parseInt(o.jifen))
            }
            n=roundReloaded(rcount / total * 100,2);
            return Math.round(n) >= 1 && 40 > Math.round(n) ? (i = t.scoreText[1].praise, s = t.scoreText[1].weixin1 + n + t.scoreText[1].weixin2, link_num = 1) : Math.round(n) >= 40 && 70 >= Math.round(n) ? (i = t.scoreText[2].praise, s = t.scoreText[2].weixin1 + n + t.scoreText[2].weixin2, link_num = 2) : Math.round(n) > 70 && 99 >= Math.round(n) ? (i = t.scoreText[3].praise, s = t.scoreText[3].weixin1 + n + t.scoreText[3].weixin2, link_num = 3) : 100 === n && (i = t.scoreText[4].praise, s = t.scoreText[4].weixin1+n+t.scoreText[4].weixin2, link_num = 4, r = !0),
            {
                score: n,
                praise: i,
                weixin: s,
                geek: r,
                jifen: total_cent
            }
        },
        pageContent: function() {
            var n = this;
            n.currIndex < n.questionList.length && (n.currIndex < total-1 && e(".fox").removeClass("active"), total-2 == n.currIndex ? (e(".button").html("最后一题"), setTimeout(function() {
                e(".fox").addClass("active")
            },
            t.duration + 10), setTimeout(function() {
                e(".button").removeClass("disabled")
            },
            t.duration + 2030)) : total-1 == n.currIndex ? e(".button").html("完成") && clearInterval(objtime) : n.currIndex == n.questionList.length - 2 && (e("#score").html(n.getScore().score), e("#praise").html(n.getScore().weixin+"<br>"+n.getScore().praise),e("#tcent").html("恭喜你获得了"+n.getScore().jifen+"积分"), e("#title").html(n.getScore().weixin), e(".button").css({
                display: "none"
            }), n.getScore().geek && setTimeout(function() {
                e("#page-share .geek").addClass("active")
            },
            t.duration + 600)));
            e.ajax({
                    type: 'POST',
                    url: "{php echo $this->createMobileUrl('index');}",
                    data: {score: n.getScore().score,tcent: n.getScore().jifen},
                    complete: function() {
                        console.log("OH HAI");
                    }
            });
        },
        next: function() {
            var n = this;
            e(".button").hasClass("disabled") || n.isRunning || (n.isRunning = !0, setTimeout(function() {
                n.isRunning = !1
            },
            t.duration + 100), n.currIndex < n.questionList.length && (n.questionList[n.currIndex + 1].element.addClass("active"), n.questionList[n.currIndex].element.addClass("aminated"), e(".button").addClass("disabled"), n.pageContent(), n.currIndex - 1 >= 0 && setTimeout(function() {
                n.questionList[n.currIndex - 1].element.removeClass("active").css({
                    display: "none"
                })
            },
            t.duration + 10), n.currIndex++, n.currIndex < n.questionList.length - 1 && n.questionList[n.currIndex + 1].element.css({
                display: "block"
            })))
        },
        init: function() {
        	clock_change();
        	var lost_time=0;
        	setInterval(function(){lost_time++;},1000)
            var n = e(".page"),
            i = this;
            if (n && n.length > 0) {
                e(n[1]).css({
                    display: "block"
                }),
                e("#praise").html(i.getScore().praise),
                i.questionList = [];
                for (var s = n.length - 1; s >= 0; s--) {
                    var r = e(n[s]);
                    i.questionList[s] = {
                        element: r,
                        point: per_cent,
                        answer: t.answer[r.attr("id")],
                        jifen: t.jifen[r.attr("id")],
                        select: null
                    }
                }
                e(document).on("tap",
                function(t) {
                    if (e(t.target).closest(".options").length > 0) {
                        var n = e(t.target).closest("li"),
                        s = n.index();
                        e(t.target).closest("li").addClass("selected").siblings("li").removeClass("selected"),
                        i.questionList[i.currIndex].select = s,
                        e(t.target).closest(".page").find(".selected").length > 0 && e(".button").removeClass("disabled")
                    }
                })
            }
            e(document).on("touchend click", ".button",
            function() {
                return i.next(),
                !1
            })
        }
    };
    n.init();
    e(".adv").on('tap',function(){ 
    	window.location.href="{php echo $sets['adv_link'];}";
    })
    e("#praise").on('tap',function(){
		if(link_num == 0){
    		window.location.href="{php echo $sets['link'];}";
    	}
    	if(link_num == 1){
    		window.location.href="{php echo $sets['link1'];}";
    	}
    	if(link_num == 2){
    		window.location.href="{php echo $sets['link2'];}";
    	}
    	if(link_num == 3){
    		window.location.href="{php echo $sets['link3'];}";
    	}
    	if(link_num == 4){
    		window.location.href="{php echo $sets['link4'];}";
    	}
    })
});
</script>
{php echo register_jssdk(false);}
<script type="text/javascript">
    initShare();
    function initShare(){
        wx.ready(function () {
            sharedata = {
                title: "{$sets['share_title']}",
                desc: "{$sets['share_content']}",
                link: window.location.href,
                imgUrl: "{$_W['attachurl']}{$sets['share_icon']}",
                success: function(){
                	 $.ajax({
	                    type: 'POST',
	                    url: "{php echo $this->createMobileUrl('share');}",
	                    complete: function() {
	                        console.log("OH HAI");
	                    }
            		});
                },
                cancel: function(){
                    //alert("分享失败，可能是网络问题，一会儿再试试？");
                }
            };
            wx.onMenuShareAppMessage(sharedata);
            wx.onMenuShareTimeline(sharedata);
        });
    }
</script>
</body>
</html>